<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 占位图
        // 先显示占位图
        // 派一个代理对象请求真实的图片地址
        // 交给这个对象
        var myImage = (function (){
            var imgNode = document.createElement('img');
            document.body.appendChild(imgNode);
            return {
                        setSrc: function(src) {
                        imgNode.src = src;
                    }
                }
        })()
        var proxyImage = (function (){
            var img=new Image();//dom 代理对象
            img.onload = function(){
                // 设置一下
                myImage.setSrc(this.src);
            }
            return {
                setSrc(src){
                    // src变量 scope
                    myImage.setSrc('https://tse1-mm.cn.bing.net/th/id/R-C.479a9262b437124e7729dea65a1b38e6?rik=Y2J09kL92ceB4g&riu=http%3a%2f%2fpic12.nipic.com%2f20110209%2f2897814_144041193193_2.gif&ehk=FdeIzybxoswa1K6DIrYvHhc39cCof7VwPzjAgmFSu48%3d&risl=&pid=ImgRaw&r=0');
                    img.src=src;
                    // console.log(src)
                }
            }
        })()
        function proxyImage (){
            this.setSrc=function(src){
                    console.log(src);
                }
        }
        proxyImage.setSrc('https://tse1-mm.cn.bing.net/th/id/R-C.f8306ead580817b2446ae92c283aae9f?rik=Z%2bAhpJTyctb9Cg&riu=http%3a%2f%2fi1.hdslb.com%2fbfs%2farchive%2f86cfa59fbda38c4007b5723b1ecaeefa6e83c0db.png&ehk=XzUgCYImbXr5gFwOhKEXbbDNfX%2f1ehP6%2bFvViqSAYOw%3d&risl=&pid=ImgRaw&r=0');
    </script>
</body>
</html>